package com.zxq.kingofbots.service.impl.pk;

import com.zxq.kingofbots.consumer.WebSocketServer;
import com.zxq.kingofbots.consumer.utils.Game;
import com.zxq.kingofbots.service.pk.ReceiveBotMoveService;
import org.springframework.stereotype.Service;

@Service
public class ReceiveBotMoveServiceImpl implements ReceiveBotMoveService {
    @Override
    public String receiveBotMove(Integer userId, Integer d) {
        System.out.println("receive"+" "+userId+" "+d);

        if(WebSocketServer.users.get(userId)!=null){
            Game game=WebSocketServer.users.get(userId).game;
            if(game!=null){
                if(game.getPlayerA().getId().equals(userId)){
                        game.setNextStepA(d);
                }else if(game.getPlayerB().getId().equals(userId)){
                        game.setNextStepB(d);
                }
            }

        }


        return "receive bot move success";
    }
}
